package quesiton;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class SettingOp {
    public static String m_modeOption;  //难度模式
    public static int m_blankAmount=10;    //填空题数
    public static int timeCount;   //考试时间
    /**设置界面**/
    public static void settings() {
        JFrame f = new JFrame("设置");
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.getContentPane().setLayout(null);
        f.setBounds(50, 50, 800, 500);
        Container container = f.getContentPane();
        JLabel label_mode = new JLabel("难度");
        label_mode.setFont(new Font("宋体", Font.PLAIN, 25));
        label_mode.setBounds(215, 160, 101,25);
        container.add(label_mode);
        //难度选择
        JComboBox comboBox_mode = new JComboBox();
        comboBox_mode.setFont(new Font("宋体", Font.PLAIN, 25));
        String [] modeOption = { "简单", "困难"};
        comboBox_mode.setModel(new DefaultComboBoxModel(modeOption));
        comboBox_mode.setSelectedIndex(0);
        comboBox_mode.setBounds(321, 160, 109, 29);
        container.add(comboBox_mode);

        JLabel mathNumber = new JLabel("题目数量");
        mathNumber.setFont(new Font("宋体", Font.PLAIN, 25));
        mathNumber.setBounds(195, 105, 101, 25);
        container.add(mathNumber);
        JLabel label_time = new JLabel("考试时间");
        label_time.setFont(new Font("宋体", Font.PLAIN, 25));
        label_time.setBounds(195, 216, 101, 25);
        container.add(label_time);

        //题目数量选择
        //String [] amountOption = {"5", "10", "15", "20", "25", "30", "35", "40", "45", "50"};
        String [] amountOption = {"2", "4", "7", "8", "10"};
        JComboBox comboBox_balnk = new JComboBox();
        comboBox_balnk.setFont(new Font("宋体", Font.PLAIN, 25));
        comboBox_balnk.setEditable(false);
        comboBox_balnk.setModel(new DefaultComboBoxModel(amountOption));
        comboBox_balnk.setBounds(321, 99, 109, 27);
        container.add(comboBox_balnk);

        //考试时间选择
        String [] timeOption = { "10",  "20",  "30", "40", "50","60","70","80","90","100"};
        JComboBox timeChoose = new JComboBox();
        timeChoose.setFont(new Font("宋体", Font.PLAIN, 25));
        timeChoose.setEditable(false);
        timeChoose.setModel(new DefaultComboBoxModel(timeOption));
        timeChoose.setBounds(321, 215, 109, 27);
        container.add(timeChoose);
        JButton button_confirm = new JButton("确认");
        button_confirm.setFont(new Font("宋体", Font.PLAIN, 25));
        button_confirm.setBounds(0, 397, 400, 47);
        button_confirm.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent arg0) {
                m_modeOption = (String) comboBox_mode.getSelectedItem();  //获得难度模式
                m_blankAmount = Integer.parseInt(comboBox_balnk.getSelectedItem().toString());  //获得题数量
                timeCount = Integer.parseInt(timeChoose.getSelectedItem().toString()); //获得考试时间
                f.dispose();
                if (comboBox_mode.getSelectedItem().equals("简单")) {
                }
                if (comboBox_mode.getSelectedItem().equals("困难")) {
                }
                f.setVisible(false);
                fillMath.doFillBlank();
                return ;
            }
        });
        container.add(button_confirm);

        JButton button_reset = new JButton("重置");
        button_reset.setFont(new Font("宋体", Font.PLAIN, 25));
        button_reset.setBounds(389, 397, 400, 47);
        button_reset.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                comboBox_mode.setSelectedItem(" ");
                comboBox_balnk.setSelectedItem("0");
                timeChoose.setSelectedItem("0");
            }
        });
        container.add(button_reset);
        JTextArea textArea_notice2 = new JTextArea("注意:\n 请务必点击\n 完提交后再\n 进入下一题");
        textArea_notice2.setBackground(Color.WHITE);
        textArea_notice2.setFont(new Font("Monospaced", Font.PLAIN, 28));
        textArea_notice2.setEditable(false);
        textArea_notice2.setBounds(555, 90, 174, 203);
        f.getContentPane().add(textArea_notice2);
        setBackground(f);
        f.setVisible(true);

    }
    public static void setBackground(JFrame f)
    {
        ImageIcon image=new ImageIcon("H:\\exam_back.jpeg");//随便找一张图就可以看到效果。
        JLabel jl=new JLabel(image);
        jl.setBounds(0, 0, 856, 616);
        f.getContentPane().add(jl);
    }

    public static void main(String[] args) {
        settings();
    }
}
